OPENPROC(3) | Linux Programmer's Manual | OPENPROC(3) |
NAME¶
openproc, closeproc - initialize process information from /proc/
SYNOPSIS¶
#include <proc/readproc.h> PROCTAB* openproc (int flags, ... );
void closeproc (PROCTAB* PT);
SYNOPSIS¶
The openproc function initializes a PROCTAB structure which can be used by iterated readproc calls to get information on current processes. Depending on flags, openproc may need a second argument or a second and third argument (see below).
closeproc closes all files opened by openproc and deallocates the memory allocated by openproc.
The PROCTAB structure is defined in <proc/readproc.h>
RETURN VALUE¶
openproc returns a pointer to a PROCTAB structure, or NULL if an error occurs. This usually means that /proc cannot be read by the process.
FLAGS¶
The behaviour of openproc is controlled by the following set of flags, which may be ORed together. There are three different kinds of flags. The first group of flags determins which information gets read from /proc/#pid for each process. The second group of flags (of which only one can be enacted for a opendir call) restricts which processes information is read for by providing a list of criteria. The third group of flags restricts this as well, but doesn't need arguments. These may be used together again.
- PROC_FILLMEM
- read information from /proc/#pid/statm.
- PROC_FILLCOM
- allocate cmdline part of proc_t and read information from /proc/#pid/cmdline.
- PROC_FILLENV
- allocate environ part of proc_t and read information from /proc/#pid/environ.
- PROC_FILLUSR
- resolve user ids to names via /etc/passwd.
- PROC_FILLGRP
- resolve group ids to names via /etc/group.
- PROC_FILLSTATUS
- read information from /proc/#pid/status.
- PROC_FILLSTAT
- read information from /proc/#pid/stat.
- PROC_FILLWCHAN
- do WCHAN lookup.
- PROC_FILLARG
- equivalent to PROC_FILLCOM.
- PROC_FILLSWAP
- read the "swap" field from /proc/#pid/smaps.
- PROC_LOOSE_TASKS
- threat threads as if they were processes.
- PROC_PID (2nd argument pid_t*pidlist)
- lookup only processes whose pid is contained in pidlist. This list must be terminated by 0.
- PROC_UID (arguments uid_t*uidlist,intn)
- lookup only processes whose user id is contained in uidlist. n is the number of uids contained in the list uidlist.
NOTE¶
Only one of the flags needing additional arguments (PROC_{PID,UID}) may be used.
SEE ALSO¶
readproc(3), readproctab(3), /proc/, /usr/include/proc/readproc.h,
20 June 2014 | Linux Manpage |